home *** CD-ROM | disk | FTP | other *** search
- ; sepod.asm rce 5/4/87 Tests COM1 at 4800,8,1,N
- ;
- ; NOTE: For this test to be successful, the following pins on the
- ; serial port connector MUST be jumpered: Jumper pins 2 and 3,
- ; jumper pins 4 and 5, and jumper pins 6 and 20.
- ;
- ; With pins jumpered as indicated above, the program will first
- ; perform an external looping test that checks the overall
- ; performance of the serial port by transmitting and receiving a
- ; series of ASCII characters. If they are received correctly
- ; they will be displayed on the screen, followed by a message that
- ; the port checks out completely. If, and only if, an error is
- ; detected, an error message is displayed, and an internal loop
- ; test is performed that checks the 8250 UART by looping back
- ; internally. If the first (external) part fails, and the second
- ; (internal) part runs, the trouble may be in the transmitter
- ; and/or receiver chips, or with one of the handshaking lines
- ; (CTS/RTS or DSR/DTR). If the second part also fails, the
- ; 8250 UART may be bad.
- ;
- ; NOTE: The overall external loop check will work on all PC's and
- ; clones, since it uses BIOS interrupts. The internal loop
- ; check, however, addresses hardware registers directly, and
- ; therefore must have the correct register addresses. Make
- ; sure that the five statements with asterisks in the comment
- ; fields all have the correct register addresses for your
- ; machines. If you cannot determine these addresses, you
- ; may want to disable the internal check part of the program
- ; by changing the statement "jna intlp" to "jmp exit" on the
- ; line with "#####". The register addresses are valid for
- ; the IBM PC, XT, AT and PS/2 Model 50.
- ;
- data segment word public 'data'
- signon db 0dh,0ah,'SEPOD Serial Port Diagnostic for COM1:',0dh,0ah
- db 'Copyright 1987, Russell C. Eberhart',0dh,0ah,0dh,0ah
- db 'You MUST have the following pins jumpered on the serial port',0dh,0ah
- db 'connector for this test to be successful:',0dh,0ah
- db 'Jumper pins 2 & 3, 4 & 5, and 6 & 20.',0dh,0ah,0dh,0ah
- db 'Testing overall port performance (external loop):',0dh,0ah,'$'
- char db '0'
- errcnt db 0h
- crlf db 0dh,0ah,0dh,0ah,'$'
- exgood db 'The COM1 serial port checks out completely OK.',0dh,0ah,'$'
- ingood db 'The internal looping check of the 8250 is OK.',0dh,0ah
- db 'You may have a problem with the transmitter',0dh,0ah
- db 'and/or receiver chips, or with the CTS/RTS',0dh,0ah
- db 'and/or DTR/DSR handshaking lines.',0dh,0ah,0dh,0ah,'$'
- exerr3 db 'ERROR: Transmitted character not received. ',0dh,0ah,'$'
- exerr1 db 'ERROR associated with character received. ',0dh,0ah,'$'
- exerr2 db 'ERROR: Character received not same as sent. ',0dh,0ah,'$'
- intchk db 0dh,0ah,'Testing internal loopback performace:',0dh,0ah,'$'
- bomb db 0dh,0ah,'The internal looping check fails. You may have a bad 8250 UART.',0dh,0ah,'$'
- data ends
- ;
- dgroup group data ;define data group, loaded last
- ;
- stack segment para stack 'stack'
- db 256 dup(0) ;reserve 256 bytes for stack
- stack ends
- ;
- code segment byte public 'code'
- assume cs:code, ss:stack, ds:dgroup
- ;
- main proc far
- ;
- ; Set up data segment
- start: mov ax,data ;set up data segment
- mov ds,ax ; into DS
- ;
- ; Initialize communciations port
- mov ah,00 ;function 0 = initialize port
- mov al,0c3h ;4800,8,N,1 (0a3h for 2400)
- mov dx,0 ;use COM1
- int 14h ;serial port service
- ;
- ; Print sign-on message
- lea dx,signon ;load address of sign-on message
- mov ah,9 ;print string service
- int 21h ;DOS function
- ;
- ; Clean out receiver data and shift registers
- ; mov cx,2 ;set up to loop twice
- ;lean: mov ah,2 ;set up read character
- ; mov dx,0 ;use COM1
- ; int 14h ;serial port service
- ; loop clean ;do twice
- ;
- ; Check external loop, transmit & receive 80 characters
- txwait: mov ah,03h ;serial port status request
- mov dx,0 ;use COM1
- int 14h ;serial port service
- test ah,20h ;transmitter hold register empty?
- jz txwait ;not empty
- ;
- mov al,char ;start with "0" character, then increment
- mov dx,0 ;use COM1
- mov ah,01h ;write character
- int 14h ;serial port service
- ;
- mov cx,0fffh ;set up 1-second loop
- wait: mov ah,3 ;status request
- mov dx,0 ;use COM1
- int 14h ;serial port service
- and ah,01h ;character ready yet?
- jnz rcv ;yes, receive it
- loop wait ;no, try again (for 1 second)
- jmp error3 ;if no success, receive char error
- ;
- rcv: mov ah,2 ;yes, read char function
- mov dx,0 ;use COM1
- int 14h ;serial port service
- and ah,08eh ;error check (09eh? break also?)
- jc error1 ;handle external receive error
- ;
- cmp al,char ;compare sent with received char
- jnz error2 ;handle garbled transmission error
- mov bx,0 ;page 0
- mov ah,0eh ;TTY display service
- int 10h ;video I/O
- ;
- inc char ;next character
- cmp char,7eh ;last character?
- jnz txwait ;no, send another char
- lea dx,crlf ;yes, load cr-lf string
- mov ah,9 ;print string service
- int 21h ;DOS function
- lea dx,exgood ;load "success" message
- mov ah,9 ;print string service
- int 21h ;DOS function
- ;
- exit: mov ah,04ch ;terminate process service
- int 21h ;DOS function (END program)
- ;
- ; External receive error reflected in AH
- error1: lea dx,exerr1 ;load line status error after rcv message
- jmp errprn ;jump to print error message
- ;
- ; Received character not same as that sent
- error2: lea dx,exerr2 ;load sent<>received char message
- jmp errprn ;jump to print error message
- ;
- ; Received character not available (bit 0 not 1)
- error3: lea dx,exerr3 ;load xmttd char not rcd error message
- errprn: mov ah,9 ;print string service
- int 21h ;DOS function interrupt
- inc errcnt ;add one to the error count
- cmp errcnt,1 ;test to see if previous error
- jna intlp ;if not, check internal loop #####
- ;
- ; If internal loop test done with error, print message and exit
- lea dx,bomb ;load total failure message
- mov ah,9 ;print string service
- int 21h ;DOS function
- jmp exit ;go to exit
- ;
- ; Set up internal loopback and test
- intlp: mov dx,3fch ;modem control register address *****
- mov al,13h ;set INTERNAL loopback
- out dx,al ;do it
- ;
- mov char,'0' ;re-start with character 0
- ;
- lea dx,intchk ;load address of internal check message
- mov ah,9 ;print string service
- int 21h ;DOS function
- ;
- intxwt: mov dx,3fdh ;line status register address *****
- in al,dx ;put line status in AL
- test al,20h ;transmitter hold register empty?
- jz intxwt ;not empty, so loop
- ;
- mov al,char ;start with "0" character, then increment
- mov dx,3f8h ;transmitter holding register address *****
- out dx,al ;send the character
- ;
- mov cx,0fffh ;set up 1-second loop
- inwait: mov dx,3fdh ;line status register address *****
- in al,dx ;put line status in AL
- test al,1eh ;receive error check
- jnz error1 ;handle external receive error
- ;
- test al,01h ;character ready yet?
- jnz inrcv ;yes, receive it
- loop inwait ;no, loop for up to 1 second
- jmp error3 ;if no success, receive char error
- ;
- inrcv: mov dx,3f8h ;receiver data register address *****
- in al,dx ;put received char in AL
- and al,7fh ;keep only valid lower 7 bits
- ;
- cmp al,char ;compare sent with received char
- jnz error2 ;handle garbled transmission error
- mov bx,0 ;page 0
- mov ah,0eh ;TTY display service
- int 10h ;video I/O
- ;
- inc char ;next character
- cmp char,7eh ;last character?
- jnz intxwt ;no, send another char
- lea dx,crlf ;yes, load cr-lf string
- mov ah,9 ;print string service
- int 21h ;DOS function
- lea dx,ingood ;load internal "success" message
- mov ah,9 ;print string service
- int 21h ;DOS function
- ;
- jmp exit ;all done, exit
- ;
- main endp
- code ends
- end start